package com.yunhe.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class JsonUtil {
    public  static void objToJson(Object obj,HttpServletResponse resp) throws IOException {
        resp.setContentType("text/html;charset=utf-8");
        ObjectMapper mapper = new ObjectMapper();
        String s = mapper.writeValueAsString(obj);
        resp.getWriter().println(s);
    }
}
